<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./js/vue2.js"></script>
    <script src="./js/vue-router.js"></script>
</head>

<body>
    <div id="app">
        <!-- 实现路由的展示区域 -->
        <router-link to="/index">首页</router-link>
        <router-link to="/login">登录页</router-link>
        <!-- 映射组件的展示区域 -->
        <router-view></router-view>
    </div>
</body>
<script>
    // 创建组件
    var index = Vue.component('index', {
        template: `<h2>首页</h2>`
    })
    var login = Vue.component('login', {
        template: `<h2>登录页</h2>`
    })
    // 创建路由对象
    var router = new VueRouter({
        // 创建路由配置
        routes: [
            { name: "index", path: "/index", component: index },
            { name: "login", path: "/login", component: login }

        ]
    })
    var vm = new Vue({
        el: "#app",
        router: router,
        data: {

        }
    })
</script>

</html>